# _*_ coding : utf-8 _*_
# @Time : 2023/3/15 0015 10:10
# @Author : 菜鸟王小二
# @File : 8_使用requests
# @Project : python爬虫

import requests
session = requests.session()

method = 'POST'
url = 'https://fanyi.baidu.com/v2transapi?from=en&to=zh'
data = {
    'from':'en',
    'to':'zh',
    'query':'test',
    'transtype':'realtime',
    'simple_means_flag':'3',
    'sign':'431039.159886',
    'token':'a4b52c90df39e15f13a98b8a5fba3eb5',
    'domain':'common',
}
headers = {
    'Cookie': 'BIDUPSID=6F7709A126BA3DE53A77104C3D401C48; PSTM=1656320516; BAIDUID=92AB31E6FB9DB4C5AA494D7DA30757A9:FG=1; BAIDUID_BFESS=92AB31E6FB9DB4C5AA494D7DA30757A9:FG=1; BA_HECTOR=0l8ga1202kaka184ak8k042p1i10df81n; ZFY=e3x:B6oLkPbOQEY9pJb4ag9MxKb5iIXd0Ew0Rr59BBMI:C; PSINO=7; delPer=0; BDRCVFR[dG2JNJb_ajR]=mk3SLVN4HKm; BDRCVFR[-pGxjrCMryR]=mk3SLVN4HKm; BDRCVFR[tox4WRQ4-Km]=mk3SLVN4HKm; ariaDefaultTheme=undefined; RT="z=1&dm=baidu.com&si=f4333bc9-a77b-4419-aeab-5c27d3bf5fb7&ss=lf80q3c2&sl=2&tt=2jx&bcn=https://fclog.baidu.com/log/weirwood?type=perf&ld=5v8&ul=6s2k&hd=6s36"; H_PS_PSSID=26350; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BCLID=10970802000874100155; BCLID_BFESS=10970802000874100155; BDSFRCVID=V8DOJexroG07VWbfL0PwulcQzLweG7bTDYrEOwXPsp3LGJLVFe3JEG0Pts1-dEu-S2OOogKK3gOTHxDF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; BDSFRCVID_BFESS=V8DOJexroG07VWbfL0PwulcQzLweG7bTDYrEOwXPsp3LGJLVFe3JEG0Pts1-dEu-S2OOogKK3gOTHxDF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF=tRAOoC_-tDvDqTrP-trf5DCShUFsLjvRB2Q-XPoO3KtbSx3Pbxk20b-0hMbIhf7f5mkf3fbgy4op8P3y0bb2DUA1y4vp0tLeWeTxoUJ2-KDVeh5Gqq-KXU4ebPRiJ-b9QgbOKpQ7tt5W8ncFbT7l5hKpbt-q0x-jLTnhVn0MBCK0HPonHj-KD6ob3f; H_BDCLCKID_SF_BFESS=tRAOoC_-tDvDqTrP-trf5DCShUFsLjvRB2Q-XPoO3KtbSx3Pbxk20b-0hMbIhf7f5mkf3fbgy4op8P3y0bb2DUA1y4vp0tLeWeTxoUJ2-KDVeh5Gqq-KXU4ebPRiJ-b9QgbOKpQ7tt5W8ncFbT7l5hKpbt-q0x-jLTnhVn0MBCK0HPonHj-KD6ob3f; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1678804524; APPGUIDE_10_0_2=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1678808876; ab_sr=1.0.1_YTFmMjMyZDUzOWMzZGQ3ODY2ZjQ4NGNlYTY1ZTllOTg0NWQ2OGQ4ZjAwOTU0YjVkMDQzMWZlZTU1OGM5N2ZlODhjYzIyZGZjMmU3YTYyZGRkNDEyYjFmODYyYzU0NjgxZDNlNjk4NTNkZjU1OTFiNGJkZjc5MzJmYTI4NjliY2MwZWUwYTllYzE2NzU2MDMyMGU4MTdjZTYwMzkwNzkzZg=='
}
# 可以使用代理
proxy = {
    'http':'116.9.163.205:58080'
}
response = session.request(method=method,url=url,data=data,headers=headers,proxies=proxy)
print(response.json())